{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5f302de4",
   "metadata": {},
   "source": [
    "# 元组（tuple）\n",
    "\n",
    "*[元组]()\n",
    ">1. 它是和list几乎完全一样的序列数据\n",
    ">2.  它与list不同的地方是，**不可变**(因为不可变，所以几乎没有方法)\n",
    ">3. 元组的形式：(1,2,34,5)对比元组()列表[]\n",
    ">4.元组是不可变的有序的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b0b1a0f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "79460290",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=10, tm_mday=25, tm_hour=12, tm_min=2, tm_sec=44, tm_wday=0, tm_yday=298, tm_isdst=0)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "69a175d7",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = \"hexue\",\"yuchang\",\"liuchang\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6bec5911",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('hexue', 'yuchang', 'liuchang')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2a4cf6be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "6add8d9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.count(\"hexue\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e006efea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.index(\"hexue\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4af0153a",
   "metadata": {},
   "source": [
    "#  字典(dict)\n",
    "\n",
    "> 1.字典的创建方式\n",
    ">> 1. 直接创建字典，按照字典的结构：{key1:value1，key2:value2,......}\n",
    ">> 2.dict()创建字典，dict(key1=value1,key2=value2,...)\n",
    "> 2.字典的性质"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "6e9596c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 第一种创建字典的方法\n",
    "stu_info = {\n",
    "    \"stu10001\":\"Alex\",\n",
    "    \"stu10002\":\"Jack\",\n",
    "    \"stu10003\":\"Marry\"\n",
    "}\n",
    "\n",
    "stu10001 = {\n",
    "    \"name\":\"Alex\",\n",
    "    \"age\":18,\n",
    "    \"Job\":\"student\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "685cc241",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Alex', 'stu10002': 'Jack', 'stu10003': 'Marry'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9e0d438f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 第二种创建字典的方法\n",
    "#与第一种的区别：\n",
    "#     1.dict() VS ()\n",
    "#     2.stu10001 VS\"stu10001\"\n",
    "#     3.  = VS :\n",
    "stu_info_02 = dict(\n",
    "   stu10001 = \"Alex\",\n",
    "   stu10002 = \"Jack\",\n",
    "   stu10003 = \"Marry\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "66bc89d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Alex', 'stu10002': 'Jack', 'stu10003': 'Marry'}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info_02"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "62798d58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Alex', 'stu10002': 'Jack', 'stu10003': 'Marry'}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 第三种创建字典的方式，新建空字典，然后增加值的方式创建字典\n",
    "\n",
    "stu_info_03 ={}\n",
    "\n",
    "stu_info_03['stu10001'] = \"Alex\" # 字典的增加\n",
    "stu_info_03['stu10002'] = \"Jack\"\n",
    "stu_info_03['stu10003'] = \"Marry\"\n",
    "stu_info_03"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "02660ab0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Alex'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info_03['stu10001']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9543118f",
   "metadata": {},
   "source": [
    "------\n",
    "\n",
    "# week09作业：\n",
    "\n",
    "> 1.请尝试使用和学习字典的方法 （必须完成）\n",
    "\n",
    "> 2.给一组数据，利用字典查询的方式尝试查找指定的数据（尝试完成）"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
